package com.tiza.xiaoyoubao.app;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by mapple on 17/2/13.
 */

public class AppConfig {
    static SharedPreferences settings;
    static SharedPreferences.Editor editor;
    static final String PREFS_NAME = "config";
    private static final String tag = AppConfig.class.getSimpleName();
    static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    @SuppressLint("CommitPrefEdits")
    public static boolean Init(Context ctx) {
        settings = ctx.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
        editor = settings.edit();
        return true;
    }
    public static boolean save() {
        return editor.commit();
    }

    /**
     * 是否有欢迎页
     */
    public static boolean hasWelcome = true;
    //判断是否绑定银行卡
    public static void setBindingBank(boolean var){
        editor.putBoolean("bankstate",var);
        save();
    }
    public static boolean getBindingBank(){
        return settings.getBoolean("bankstate",false);
    }

    //每天发送短信的最大次数
    public static void setSendVerTime(int time){
        editor.putInt("sendVertime",time);
        save();
    }
    public static int getSendVerTime(){
        return settings.getInt("sendVertime",1);
    }
    //发送短信的日期
    public static void setSendVerDate(String date){
        editor.putString("sendVerDate",date);
        save();
    }
    public static String getSendVerDate(){
        return settings.getString("sendVerDate",format.format(new Date()));
    }
}
